package com.qf.bank.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 惠佳旭
 * @date 2019/12/4
 */
@Configuration
public class RabbitmqRedisConfig {
  @Bean
  public Queue redisStringQueue() {
    return new Queue("topic.redis.string");
  }

  @Bean
  public Queue redisHashQueue() {
    return new Queue("topic.redis.hash");
  }

  @Bean
  public Queue redisListQueue() {
    return new Queue("topic.redis.list");
  }

  @Bean
  public Queue redisSetQueue() {
    return new Queue("topic.redis.set");
  }

  @Bean
  public Queue redisZsetQueue() {
    return new Queue("topic.redis.zset");
  }

  @Bean
  public Binding bindRedisStringExchange(Queue redisStringQueue, TopicExchange topicExchange) {
    return BindingBuilder.bind(redisStringQueue).to(topicExchange).with("topic.redis.string");
  }

  @Bean
  public Binding bindRedisHashExchange(Queue redisHashQueue, TopicExchange topicExchange) {
    return BindingBuilder.bind(redisHashQueue).to(topicExchange).with("topic.redis.hash");
  }

  @Bean
  public Binding bindRedisListExchange(Queue redisListQueue, TopicExchange topicExchange) {
    return BindingBuilder.bind(redisListQueue).to(topicExchange).with("topic.redis.list");
  }

  @Bean
  public Binding bindRedisSetExchange(Queue redisSetQueue, TopicExchange topicExchange) {
    return BindingBuilder.bind(redisSetQueue).to(topicExchange).with("topic.redis.set");
  }

  @Bean
  public Binding bindRedisZetExchange(Queue redisZsetQueue, TopicExchange topicExchange) {
    return BindingBuilder.bind(redisZsetQueue).to(topicExchange).with("topic.redis.zset");
  }
}
